package com.example.administrator.demoa;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class addActivity extends AppCompatActivity {
private EditText edtstuno;
    private EditText edtname;
    private EditText edtage;
    private Button btnSave;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_add);
        edtstuno=findViewById(R.id.edt_stuno);
        edtname=findViewById(R.id.edt_name);
        edtage=findViewById(R.id.edt_age);
        btnSave=findViewById(R.id.btn_save);

        btnSave.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String stuno=edtstuno.getText().toString();
                String name=edtname.getText().toString();
                int age=Integer.parseInt(edtage.getText().toString());
                Intent intent =new Intent();
                intent.putExtra("stuno",stuno);
                intent.putExtra("name",name);
                intent.putExtra("age",age);
                setResult(2001,intent);
                finish();
            }
        });
    }
}
